import React, { Component } from 'react';
import { Modal, Form, Input, InputNumber, Button } from 'antd'

const FormItem = Form.Item;
// const Button = Form.Button
const formItemLayout = {
  labelCol: { span: 6 },
  wrapperCol: { span: 18 }
};
const formItemLayout1 = {
  labelCol: { span: 7 },
  wrapperCol: { span: 17 }
};
const confirm = Modal.confirm;
class RechargeModal extends Component {

  handleOk = () => {
    const { getFieldsValue, validateFields } = this.props.form
    validateFields((errors) => {
      if (errors) {
        return
      }
      const data = {
        pc: "pc",
        ...getFieldsValue(),
      }
      console.log('data:', data)
      this.props.getrecharge(data)
    })
  }

  onDeleteRecharge = () => {
    confirm({
      title: `是否确认会员充值吗`,
      okText: '确认',
      okType: 'primary',
      cancelText: '取消',
      onOk: () => {
        this.handleOk()
        this.props.onCancelRecharge()
      },
    });
  }




  render() {
    const { getFieldDecorator } = this.props.form
    const { modalVisibleone } = this.props
    console.log("itemsss", this.props)
    return (
      <Modal title="会员充值"
        width={350}
        onOk={this.onDeleteRecharge}
        onCancel={this.props.onCancelRecharge}
        visible={modalVisibleone}
      >
        <Form>
          <FormItem label="会员充值"  {...formItemLayout}>
            {getFieldDecorator('money', {
              initialValue: '',
              rules: [{
                required: true,
                message: '请输入金额',
              }],
            })(
              <InputNumber placeholder="请输入充值金额" min={1} style={{ width: '210px' }} />
            )}
          </FormItem>
          <FormItem label="验证码" {...formItemLayout}>
            {getFieldDecorator('code', {
              initialValue: '',
              rules: [{
                required: true,
                message: '请输入验证码'
              }]
            })(
              <InputNumber placeholder="请输入验证码" style={{ width: '210px' }} />
            )}
          </FormItem>
          <FormItem>
            <Button type="primary" onClick={() => this.props.getCode()}>点击发送验证码</Button>
          </FormItem>
        </Form>
      </Modal >
    );
  }
}

export default Form.create()(RechargeModal);
